package com.ldr.custom.spring.v3.aop;


import com.ldr.custom.spring.v3.aop.support.GPAdvisedSupport;

/**
 * 静态aop代理工厂
 */
public class GPDefaultAopProxyFactory {

    private static GPDefaultAopProxyFactory GPDefaultAopProxyFactory = new GPDefaultAopProxyFactory();

    public static GPDefaultAopProxyFactory getInstance() {
        return GPDefaultAopProxyFactory;
    }

    public GPAopProxy createAopProxy(GPAdvisedSupport advised) {
        Class<?> targetClass = advised.getTargetClass();
        if (targetClass.getInterfaces().length > 0) {
            return new GPJdkDynamicAopProxy(advised);
        } else {
            return new GPCglibAopProxy(advised);
        }

    }

}
